/**
 *
 * Created by lemuelwang on 2017/2/22.
 */


qui(
    function (require, exports, module) {

        Director.Dao = $.extend({}, EpgWeb.Dao, Ancestor.Dao, {

            logType: function () {
                return this.getDataByName(this.cfgName.LogType);
            },
            releaseAllDirector: function (data, callback) {
                var options = {
                    url: Director.urlConfig.releaseAllUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/releaseAll');
            },
            releaseDirector: function (data, callback) {
                var options = {
                    url: Director.urlConfig.releaseUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/release');
            },

            stopDirector: function (data, callback) {
                var options = {
                    url: Director.urlConfig.stopUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };

                Ancestor.Dao.ajax(options, '/director/stop');
            },



            startDirector: function (data, callback) {
                var options = {
                    url: Director.urlConfig.startUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/start');
            },
            getDirector:function(data, callback){
                var options = {
                    url: Director.urlConfig.listUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/list');
            },
            editDirector: function (data, callback) {
                var options = {
                    url: Director.urlConfig.editUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/edit');
            },
            getResourceList: function (data, callback) {
                var options = {
                    url: Director.urlConfig.resourceListUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/resource/getList');
            },
            addResource: function (data, callback) {
                var options = {
                    url: Director.urlConfig.addResourceUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/resource/add');
            },
            delResource: function (data, callback) {
                var options = {
                    url: Director.urlConfig.delResourceUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/resource/del');
            },
            editResource: function (data, callback) {
                var options = {
                    url: Director.urlConfig.editResourceUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/resource/edit');
            },

            switchBackUp: function (data, callback) {
                var options = {
                    url: Director.urlConfig.switchBackUpUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/backup/switch');
            },
            switchResource: function (data, callback) {
                var options = {
                    url: Director.urlConfig.switchResourceUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/resource/switch');
            },
            addEffect: function (data, callback) {
                var options = {
                    url: Director.urlConfig.effectAddUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/effect/add');
            },
            editEffect: function (data, callback) {
                var options = {
                    url: Director.urlConfig.effectEditUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/effect/edit');
            },
            deleteEffect: function (data, callback) {
                var options = {
                    url: Director.urlConfig.effectDelUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/effect/del');
            },

            getEffectList: function (data, callback) {
                var options = {
                    url: Director.urlConfig.effectListUrl,
                    dataType: 'json',
                    data: data,
                    method: 'get',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/effect/list');
            },


            redirectApi: function (data, callback) {
                var options = {
                    url: '/api/director/redirect',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    beforeSend: function (request) {
                        var auth = Ancestor.Util.getAuth('/redirect');
                        request.setRequestHeader('Sign', auth.sign);
                        request.setRequestHeader("Time", auth.clientTime);
                        request.setRequestHeader("From", auth.from);
                    },
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/redirect');
            },

            getProgram: function (data, callback) {
                var options = {
                    url: Director.urlConfig.programSearchUrl,
                    dataType: 'json',
                    data: data,
                    method: 'get',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/program/search');
            },
            quickCreatePreviewUrl: function (data, callback) {
                console.log("wait to do");
//                var options = {
//                    url: Director.Constant.thirdUrl_quick_create_preview,
//                    dataType: 'json',
//                    data: data,
//                    method: 'get',
//                    success: function (data) {
//                        callback.call(this, data);
//                    },
//                    error: function (data) {
//                        callback.call(this, data);
//                    }
//                };
//                Ancestor.Dao.ajax(options);
                callback();
            },

            getCommentaryList: function (data, callback) {
                var options = {
                    url: Director.urlConfig.commentaryListUrl,
                    dataType: 'json',
                    data: data,
                    method: 'get',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/commentary/list');
            },

            deleteCommentary: function(data, callback) {
                var options = {
                    url: Director.urlConfig.commentaryDelUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/commentary/del');
            },
            editCommentary: function(data, callback) {
                var options = {
                    url: Director.urlConfig.commentaryEditUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/commentary/edit');
            },
            setDirectorMainResource: function (data, callback) {
                var options = {
                    url: Director.urlConfig.directorSetMainResourceUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/setMainResource');
            },
            setResourcePlayCounts: function (data, callback) {
                var options = {
                    url: Director.urlConfig.setResourcePlayCountsUrl,
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/director/resource/setPlayCounts');
            },
        });

        Director.Dao.cfgName = $.extend({}, EpgWeb.Dao.cfgName, {
            LogType: "director_log",
            oldDelay: -1
        });


    }
);

